//
// Created by Asus on 2025/5/13.
//

#include "singleton.h"
#include <iostream>

Singleton *Singleton::instance = nullptr; // 初始化静态成员

Singleton::Singleton() {
    std::cout << "Singleton created" << std::endl;
}

Singleton *Singleton::getInstance() {
    if (instance == nullptr) {
        instance = new Singleton();
    }
    return instance;
}

void Singleton::doSomething() {
    std::cout << "Singleton is working" << std::endl;
}

Singleton *singleton = Singleton::getInstance(); // 定义全局实例
